package utils;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
/**
 * sp：包含多种工具类
 * 1、重启java视图界面的客户端的方法
 * @author 风蚕
 *
 */
public class AppUnits
{
    public static void restartApplication(String surl)
    {
        final String javaBin = System.getProperty("java.home") + File.separator
                + "bin" + File.separator + "java";
        final File currentJar = new File(surl);
        /* is it a jar file? */
        if (!currentJar.getName().endsWith(".jar"))
            return;

        /* Build command: java -jar application.jar */
        final ArrayList<String> command = new ArrayList<String>();
        command.add("java");
        command.add("-jar");
        command.add(currentJar.getPath());
        

        final ProcessBuilder builder = new ProcessBuilder(command);
        
        try
        {
            builder.start();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        System.exit(0);
    }
}
